﻿--[[
   @brief    game_card_tips_view 
   @author   hqzheng
   @version  1.0
   @date     2018-07-17
--]]

game_card_tips_view = 
{
    pDialog_ = nil;
    dwRootId_ = 0;
}

function game_card_tips_view:init()
    base_utility.log("[game_card_tips_view] init ");
end

function game_card_tips_view:show(bShow, ext_param)
    if self:create(ext_param) == true then
        if bShow then
            self.pDialog_:Show(TRUE);
            self.pDialog_:Restore();
            self.pDialog_:BringToTop();
        else
            self.pDialog_:Show(FALSE);
        end
    end
end

function game_card_tips_view:is_created()
    if self.pDialog_ then
        return true;
    else
        return false;
    end
end

function game_card_tips_view:is_show()
    local showed = false;
    if self.pDialog_ then
        if self.pDialog_:IsVisible() == TRUE then
            showed = true;
        end
    end
    return showed;
end

function game_card_tips_view:create(ext_param)
    if self.pDialog_ then
        game_card_tips_model.is_already_exist = true;
        return true;
    end

    self.dwRootId_ = layout_mgr.restore_layout("game_card_tips.tpf");
    
    if self.dwRootId_ ~= 0 then
        self.pDialog_ = ui_utility.get_ctrl_ptr_by_id(self.dwRootId_);
        local pWebCtrl = ui_utility.get_ctrl_ptr_by_cid(CID_WEB_CTRL_FOR_GAME_CARD_TIPS);
        local url = "/card/popup.html";
        local dst_url = web_utility.make_ptlogin_url(url, "https");
        local ui_str, str_holder = U8toCUIStr(dst_url);
        if pWebCtrl then
            pWebCtrl:Navigate(ui_str);
        end
        return true;
    else
        base_utility.log("[game_card_tips_view] game_card_tips_view error!!!");
        return false;
    end
end

function game_card_tips_view:hide(uilib, ctrl_id)
    base_utility.log("[game_card_tips_view] remove game_card_tips_view tpf");
    layout_mgr.delay_remove_ctrl(self.dwRootId_);
    self.dwRootId_ = 0;
    self.pDialog_ = nil;
end

function game_card_tips_view:close()
    self.pDialog_:Show(FALSE);
end

game_card_tips_view.init();

